package com.wty.design.creational.singleton;

import java.io.*;

public class SerializableTest {
    public static void main(String args[]) throws IOException, ClassNotFoundException {


        HungrySingleton instance=HungrySingleton.getInstance();

        ObjectOutputStream objOut=new ObjectOutputStream(new FileOutputStream("111.txt"));
        objOut.writeObject(instance);
        objOut.flush();
        objOut.close();

        ObjectInputStream objIn=new ObjectInputStream(new FileInputStream("111.txt"));
        HungrySingleton instance2= (HungrySingleton) objIn.readObject();
        System.out.println(instance==instance2);

    }
}
